#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<windows.h>

/*
Erik Lawing CS362 Software Engineering II Assignment 4

Points possible: 20

(60 points) Write a random testers for two Dominion cards, one of which has to be the adventurer card. Check these random testers in as randomtestcard.c and randomtestadventurer.c.
(20 points) Add rules to and check in the Makefile to produce randomtestcard.out and randomtestadventurer.out.
(20 points) Write up and check in the development of your random testers, including improvements in coverage and effort to check the correctness of your specification, as randomhistory.txt. Be detailed and thorough!

*/
char inputChar()
{
    // TODO: rewrite this function

	const int RANGE_MAX=126;
	int c;

	c=rand()%RANGE_MAX;
	return (char)c;
}

 void inputString(char *s)
{
    // TODO: rewrite this function

	int i;

	for(i=0;i<7;i++){

		s[i]=inputChar();

	}
	return;
}

void testme()
{
  int tcCount = 0;
  char *s;
  s=malloc(sizeof(char)*6);

  char c;
  int state = 0;
  while (1)
  {
    tcCount++;
    c = inputChar();
    inputString(s);

    printf("Iteration %d: c = %c, s = %s, state = %d\n", tcCount, c, s, state);

    if (c == '[' && state == 0) state = 1;
    if (c == '(' && state == 1) state = 2;
    if (c == '{' && state == 2) state = 3;
    if (c == ' ' && state == 3) state = 4;
    if (c == 'a' && state == 4) state = 5;
    if (c == 'x' && state == 5) state = 6;
    if (c == '}' && state == 6) state = 7;
    if (c == ')' && state == 7) state = 8;
    if (c == ']' && state == 8) state = 9;

    if (s[0] == 'r' && s[1] == 'e' && s[2] == 's' && s[3] == 'e' && s[4] == 't' && s[5] == '\0' && state == 9)
    {
      printf("error ");
      exit(200);
    }

  }
}


int main(int argc, char *argv[])
{
    srand(time(123456));
    testme();
    return 0;
}
